import esdk from '../lib/@cloud/esdk-obs-browserjs-3.21.8.min'// (无效放pubilc下面[文档地址：https://support.huaweicloud.com/sdk-browserjs-devg-obs/obs_24_0502.html])
// // 创建ObsClient实例
const obsClient = new esdk({
  access_key_id: 'FTDWTSB3K0U0HLEBGX5L',
  secret_access_key: '10LLgl45bcxpXYKXmea6BIlC3W6mJkt4FYX1rWZA',
  server: 'obs.cn-east-3.myhuaweicloud.com'
})
export function obs(SourceFile, name) {
  return new Promise((resolve, reject) => {
    obsClient.putObject({
      Bucket: 'power-market',
      Key: `parent_directory/${name}`,
      SourceFile: SourceFile // localfile为待上传的本地文件路径，需要指定到具体的文件名
    }, (err, result) => {
      if (err) {
        console.error('Error-->' + err)
        reject({ err: err })
      } else {
        console.log('Status-->' + result.CommonMsg.Status)
        resolve({ status: result.CommonMsg.Status })
      }
    })
  })
}
